#include <iostream>
#include <vector>
#include <algorithm>
#include <climits>

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int N, K;
    cin >> N >> K;
    vector<int> A(N);
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
    }
    sort(A.begin(), A.end());

    long long min_time = LLONG_MAX;
    for (int i = 0; i <= N - K; ++i) {
        int left = A[i];
        int right = A[i + K - 1];
        long long cost;
        if (left <= 0) {
            cost = right - 2LL * left;
        } else {
            cost = right;
        }
        if (cost < min_time) {
            min_time = cost;
        }
    }
    cout << min_time << '\n';

    return 0;
}